﻿function User() {
    var self = this;
    self.ShowWindow = function(dataList) {

        var ids = new Array();
        var list = $("#dataList").DataTable().rows({ selected: true }).data();
        $.each(list,
            function(index, item) {
                ids.push(item.id);
            });

        if (ids.length === 0) {
            window.app.message("请选中一项。");
            return;
        }
        if (ids.length > 1) {
            window.app.message("只能选中一项。");
            return;
        }


        var $remote = "/Permission/Index/?owner=user&ownerId=" + ids[0], $modal = $('<div id="ajaxModal">用来做容器</div>');
        parent.$('body').append($modal);

        $modal.load($remote,
            function() {
                var newmodal = $modal.children("div").modal();
                newmodal.modal('show');
            });
    }
    //档案
    self.File = function() {
        var ids = new Array();
        var list = $("#dataList").DataTable().rows({ selected: true }).data();
        $.each(list,
            function (index, item) {
                ids.push(item.id);
            });

        if (ids.length === 0) {
            window.app.message("请选中一项。");
            return;
        }
        if (ids.length > 1) {
            window.app.message("只能选中一项。");
            return;
        }

        var $remote = "/Employee/Edit/?Id=" + ids[0], $modal = $('<div></div>');
        $modal.attr("tips", "用来作容器");
        parent.$('body').append($modal);

        $modal.load($remote,
            function () {
                var newmodal = $modal.children("div").modal();
                newmodal.modal('show');
            });
    }
    self.ShowRoleWindow = function() {
        var ids = new Array();
        var list = $("#dataList").DataTable().rows({ selected: true }).data();
        $.each(list, function (index, item) {
            ids.push(item.id);
        });

        if (ids.length === 0) {
            window.app.message("请选中一项。");
            return;
        }
        if (ids.length > 1) {
            window.app.message("只能选中一项。");
            return;
        }

        parent.$('#ajaxModal').remove();

        var $remote = "/Platform/Role/LoadWindowForUser/?userId=" + ids[0]
            , $modal = $('<div tips="用来做容器"></div>');
        parent.$('body').append($modal);

        $modal.load($remote, function () {
            var newmodal = $modal.children("div").modal();
            newmodal.modal('show');
        });
    }
}